<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="author" content="Dominik Reichl" />

	<meta name="description" content="KeePass is an open source password manager. Passwords can be stored in highly-encrypted databases, which can be unlocked with one master password or key file." />
	<meta name="keywords" content="KeePass, Password, Safe, Security, Database, Encryption, Secure, Manager, Open, Source, Free, Code, Key, Master, Disk, Dominik, Reichl" />

	<meta name="robots" content="index" />

	<meta name="DC.Title" content="KeePass - The Open Source Password Manager" />
	<meta name="DC.Creator" content="Dominik Reichl" />
	<meta name="DC.Subject" content="Open-Source Password Safe" />
	<meta name="DC.Description" content="KeePass is an open source password manager. Passwords can be stored in highly-encrypted databases, which can be unlocked with one master password or key file." />
	<meta name="DC.Publisher" content="Dominik Reichl" />
	<meta name="DC.Contributor" content="Dominik Reichl" />
	<meta name="DC.Type" content="text" />
	<meta name="DC.Format" content="text/html" />
	<meta name="DC.Identifier" content="http://keepass.info/" />
	<meta name="DC.Language" content="en" />
	<meta name="DC.Rights" content="Copyright (c) 2003-2013 Dominik Reichl" />

	<title>KPS Script Files - KeePass</title>
	<base target="_self" />
	<link rel="stylesheet" type="text/css" href="../../default.css" />
	
</head>
<body>




<table class="sectionsummary"><tr><td width="68px">
<img src="../images/b64x64_konsole.png" width="64px" height="64px"
class="singleimg" align="left" alt="Console" />
</td><td valign="middle"><h1>KPS Script Files</h1><br />
How to use KPS script files to automate KeePass 2.x.
</td></tr></table>

<p>KPS script files are a lot more powerful than single command operations,
but are also more complicated. You need
to have heavy experience in C# programming and the KeePass 2.x internals.
Within KPS files you can do everything that KeePass does.</p>

<p><b>What are KPS files?</b></p>

<p>KPS files are C# files that are loaded,
compiled and executed by the <code>KPScript.exe</code> program.
Within the script file, you got full access to the KeePass internals.</p>

<p>The main differences to &quot;normal&quot; C# files are:</p>

<ul>
<li>No need for <code>using</code> directives.</li>
<li>No need to add a reference to the KeePass assembly.</li>
<li>No need to write a wrapper class. Simply start with <code>Main()</code>. The
complete script file is embedded in a static class.</li>
</ul>

<p>Here's the famous Hello World program as KPS script:</p>

<pre><font color="#0000FF">public static void</font> Main()
{
	<font color="#008888">MessageService</font>.ShowInfo(<font color="#880000">&quot;Hello World!&quot;</font>);
}</pre>

<p>For the most important namespaces, KPScript automatically adds
<code>using</code> directives at the start of the file before compiling it.
<code>MessageService</code> for example is located in <code>KeePassLib.Utility</code>,
but as it's included automatically by KPScript, you can use it directly.</p>

<hr />

<p><b>Executing a KPS file:</b></p>

<p>To run a KPS file, you simply pass it to KPScript:</p>

<pre>KPScript.exe C:\KeePass\MyScriptFile.kps</pre>

<p>It is important that the file extension is <code>.kps</code>, otherwise KPScript won't
recognize the file and will interpret it as database for single command operations.</p>

</body></html>

